﻿using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace GPainter.ElementViews
{
    public class EdgeView
    {
        public Line Line;//дуга
        public string Id;
        public TextBlock Txt;//подпись над дугой
        public TextBlock TxtStart;//подпись над началом дуги
        public TextBlock TxtEnd;//подпись над концом дуги
        public Polygon Arrow { get; set; }//стрелочка
        public Path RoundedEdge { get; set; }//скругленная дуга
        public ArcSegment Arc { get; set; }
        public PathFigure Pf { get; set; }
        public PathGeometry Pg { get; set; }

        private bool _isSelected;
        public bool IsSelected
        {
            get
            {
                return _isSelected;
            }
            set
            {
                _isSelected = value;
                if (value)
                {
                   
                    //if (txt.Text == "sub")
                    //{
                    //    line.Stroke = Brushes.Red;
                    //    txt.Background = Brushes.Red;
                    //    tArrow.Fill = Brushes.Red;
                    //    tArrow.Stroke = Brushes.Red;
                    //    roundedEdge.Stroke = Brushes.Red;
                    //}
                    //else if(txt.Text == "is_a")
                    //{
                    //    line.Stroke = Brushes.Green;
                    //    txt.Background = Brushes.Green;
                    //    tArrow.Fill = Brushes.Green;
                    //    tArrow.Stroke = Brushes.Green;
                    //    roundedEdge.Stroke = Brushes.Green;
                    //}
                    Line.Stroke = Brushes.Yellow;
                    Txt.Background = Brushes.Yellow;
                    TxtEnd.Background = Brushes.Yellow;
                    TxtStart.Background = Brushes.Yellow;
                    //tArrow.Fill = Brushes.Green;
                    //tArrow.Stroke = Brushes.Green;
                    //roundedEdge.Stroke = Brushes.Green;
                  
                }
                else
                {
                    Line.Stroke = Brushes.Black;
                    Txt.Background = Brushes.LightBlue;
                    TxtEnd.Background = Brushes.LightBlue;
                    TxtStart.Background = Brushes.LightBlue;
                    //tArrow.Fill = Brushes.Black;
                    //tArrow.Stroke = Brushes.Black;
                    //roundedEdge.Stroke = Brushes.Black;
                }

            }
        }

        public EdgeView(string id)
        {
            Line = new Line {Stroke = Brushes.Black, StrokeThickness = 2};
            Txt = new TextBlock();
            _isSelected = false;
            Txt.Background = Brushes.LightBlue;
            Txt.FontSize = 14;
            Txt.FontFamily = new FontFamily("Comic Sans MS");
            TxtEnd = new TextBlock();
            TxtStart = new TextBlock();
            TxtEnd.Background = Brushes.LightBlue;
            TxtEnd.FontSize = 14;
            TxtEnd.FontFamily = new FontFamily("Comic Sans MS");
            TxtStart.Background = Brushes.LightBlue;
            TxtStart.FontSize = 14;
            TxtStart.FontFamily = new FontFamily("Comic Sans MS");
            Id = id;
            //создаем стрелочку у конечной вершинки
            Arrow = new Polygon();
            Arrow.Points.Add(new System.Windows.Point(5, 0));
            Arrow.Points.Add(new System.Windows.Point(10, 5));
            Arrow.Points.Add(new System.Windows.Point(0, 5));
            Arrow.Stroke = Brushes.Black;
            Arrow.Fill = Brushes.Black;

            //для параллельных дуг
            RoundedEdge = new Path {Stroke = Brushes.Black, StrokeThickness = 2};

            Arc = new ArcSegment();
            Pf = new PathFigure();
            Pg = new PathGeometry();

            Pf.IsClosed = false;
            Pf.Segments.Add(Arc);
            Pg.Figures.Add(Pf);
            RoundedEdge.Data = Pg;
        }

    }
}
